#include <reg51.h>
#include <stdio.h>
/*--------------------------------------------------------*/
/*void delay10ms(void) 

{ 
  unsigned char i, j, k;

  for(i=5;i>0;i--) 

    for(j=4;j>0;j--)

      for(k=248;k>0;k--); 
}
void delay(unsigned char i)
{
  for( ; i != 0; i--)
     {
      delay10ms();
     }
}*/
/*---------------------------------*/
char rx_char()
{
  while(1)  if(RI) break;
  RI=0;
  return SBUF;
}
/*------------------------*/
tx_char(unsigned char c)
{
  while(1) if(TI) break;
  TI=0;
  SBUF=c;
}
/*--------------------------------------------------------*/
init_rs232()       /* <9600 N 8 1>  */
{
  SCON=0x50;
  TMOD=0x20;
  TH1 =0xFD;
  TR1=1;
  TI =1;
}
/*-----------------*/
main()
{
  unsigned char x;
  //unsigned char n;
  init_rs232();
  while(1)
   {
   x=rx_char();
   if(x=='s')
   	{
		//delay(1);
		//n=P0;
		tx_char(P0);
    	//printf("%c",P0);
        //delay(1);
	}
   }
  /* while(1)
   {
		x=rx_char();
		if(x=='s'){break;}
   }*/
}
/*---------------------*/
